<%@page import="doantotnghiep.modelDTO.MedicamentDTO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="doantotnghiep.modelDTO.CustomerDTO"%>
<%@page import="doantotnghiep.modelDTO.PurchaseOrderDTO"%>
<%@page import="doantotnghiep.modelDTO.StaffDTO"%>

<%@page import="java.util.List"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Đơn Đặt Hàng</title>
<script type="text/javascript">
	$(function() {
		$("#deliveryDate").datepicker();
		$("#orderDate").datepicker();
	});
</script>

</head>
<body>

	<%
		HashMap<String, Object> purchaseModel = (HashMap<String, Object>) request
				.getAttribute("purchaseModel");
	%>
	<br>
	<br>
	<div align="center">
		<h1 style="color: blue;">LẬP ĐƠN BÁN HÀNG</h1>
		<br> <br>
		<form:form method="POST" commandName="PurchaseOrderDTO">
			<table border="1">
				<tr>
					<td><form:label path="orderedDate">Ngày đặt hàng:</form:label></td>
					<td><form:input id="orderDate" path="orderedDate" value="" /></td>
					<td><span id="orderDate-error" style="color:red"> </span></td>
					
				</tr>
				<tr>
					<td><form:label path="deliveryDate">Ngày giao hàng:</form:label></td>
					<td><form:input id="deliveryDate" path="deliveryDate" value="" /></td>
					<td><span id="deliveryDate-error" style="color:red"> </span></td>
				</tr>
				<tr>
					<td><form:label path="deliveryLocation">Nơi giao hàng:</form:label></td>
					<td><form:input id="deliveryLocation" path="deliveryLocation" value="" /></td>
					<td><span id="deliveryLocation-error" style="color:red"> </span></td>
				</tr>
				<tr>
					<td><form:label path="customer_ID">Tên khách hàng:</form:label></td>
					<td><form:select path="customer_ID" value="${customer_ID}">
							<%
								if (purchaseModel != null) {
											ArrayList<CustomerDTO> customers = (ArrayList<CustomerDTO>) purchaseModel
													.get("customerDTOs");
											if (customers != null) {
												for (int i = 0; i < customers.size(); i++) {
							%>
							<option value="<%=customers.get(i).getId()%>"><%=customers.get(i).getFullName()%></option>
							<%
								}
											}
										}
							%>
						</form:select></td>
				</tr>
				<tr>
					<td><form:label path="staff_ID">Nhân viên:</form:label></td>
					<td><form:select path="staff_ID" value="${staff_ID}">
							<%
								if (purchaseModel != null) {
											ArrayList<StaffDTO> staffs = (ArrayList<StaffDTO>) purchaseModel
													.get("staffDTOs");
											if (staffs != null) {
												for (int i = 0; i < staffs.size(); i++) {
							%>
							<option value="<%=staffs.get(i).getId()%>"><%=staffs.get(i).getFullName()%></option>
							<%
								}
											}
										}
							%>

						</form:select></td>
				</tr>
			</table>
		</form:form>

	</div>
	<br>
	<br>
	<br>
	<br>
	<br>
	<br>
</body>
</html>